package com.xwt.pattern.iterator;

import java.util.ArrayList;

/**
 * Author:  Steven Xiao
 * Description:所有项目的信息类
 * Date:  2016/3/23
 * Time:  15:42
 */
public class Project implements IProject {
    //定义一个项目列表，所有的项目都放在这里
    private ArrayList<IProject> projectList = new ArrayList<>();

    //项目名称
    private String name = "";

    //项目成员数量
    private int num = 0;

    //项目费用
    private int cost = 0;

    public Project() {

    }

    //定义一个构造函数，把所有老板需要看到的信息存储起来
    public Project(String name, int num, int cost) {
        this.name = name;
        this.num = num;
        this.cost = cost;
    }

    @Override
    public void add(String name, int num, int cost) {
        this.projectList.add(new Project(name, num, cost));
    }

    @Override
    public String getProjectInfo() {
        StringBuilder sb = new StringBuilder();
        sb.append("项目的名称是：");
        sb.append(this.name);
        sb.append("\t");
        sb.append("项目人数：");
        sb.append(this.num);
        sb.append("\t");
        sb.append("项目费用：");
        sb.append(this.cost);
        return sb.toString();
    }

    @Override
    public IProjectIterator iterator() {
        return new ProjectIterator(this.projectList);
    }
}
